using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace VoltGameEditor
{
    static class Program
    {
		static public FIRST_RUN FIRST_RUN;
        static public MainWin mainWin;
		static public functions Functions;
		static public contole Console;
		static public searchOpts SearchOpts;
		//static public AboutBox About;
		static public SettingsDiag Settings;
		static public Splush Splash;
		static public keymap KeyMap;
        static public twoDeeDiag twoDeeDiag;
		static public PrefabFactory Prefabs;
        static public ValueEditor ValEditor;
        //static public custObj CustObj;
        static public StartPage startPage;
		static public progBarModal PbModal;
		//static public MaterialBrowser MatBrowser;
		static public ObjectPane ObjPane;
		//static public buildCfg buildCFG;
        

        //classes

        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

			//forms
			FIRST_RUN = new VoltGameEditor.FIRST_RUN();
			Console = new contole();
			Splash = new Splush();
            mainWin = new MainWin();
			Functions = new functions();
			SearchOpts = new searchOpts();
			//About = new AboutBox();
			Settings = new SettingsDiag();
			KeyMap = new keymap();
            twoDeeDiag = new VoltGameEditor.twoDeeDiag();
			Prefabs = new PrefabFactory();
            ValEditor = new ValueEditor();
           // CustObj = new custObj();
            startPage = new StartPage();
			PbModal = new progBarModal();
			//MatBrowser = new MaterialBrowser();
			ObjPane = new ObjectPane();
			//buildCFG = new buildCfg();

			DoSplash();

			Application.Run(mainWin);
        }

		static void DoSplash()
		{
			Program.Splash.Show(); 
			Program.Splash.status.Text = "Checking for settings file...";
			Program.Splash.Refresh();
			if (System.IO.File.Exists("MainSettings.ini"))
			{   //Proceed to import settings...
				Program.Splash.status.Text = "Restoring settings...";
				Program.Splash.Refresh();

				AppSettings.ReadMainSettingsINI();
			}
			else
			{
				Program.Splash.status.Text = "No settings file found, loading defaults...";
                AppSettings.SetDefaults();
				Program.Splash.Refresh();
			}
            if (AppSettings.General.AutoUpdate == true)
			{
				Program.Console.rtb_errors.Text += "\nUnable to reach update server\n\n";
			}
			Program.Splash.status.Text = "Starting up...";
			Program.Splash.Refresh();

			System.Threading.Thread.Sleep(1000);

			Program.Splash.DoTimer();
		}
		
    }
	
}